; (function () {
    // 数据
    const obj = {
        message: '获取面板数据成功',
        data: {
            // 数据看板的数据
            overview: {
                salary: 16376,
                student_count: 80,
                age: 24,
                group_count: 8,
            },
            // 全学科薪资走势
            year: [
                { month: '1月', salary: 14800 },
                { month: '2月', salary: 13600 },
                { month: '3月', salary: 21400 },
                { month: '4月', salary: 15100 },
                { month: '5月', salary: 15000 },
                { month: '6月', salary: 17000 },
                { month: '7月', salary: 18700 },
                { month: '8月', salary: 20100 },
                { month: '9月', salary: 12600 },
                { month: '10月', salary: 14300 },
                { month: '11月', salary: 12200 },
                { month: '12月', salary: 19600 },
            ],
            // 籍贯分布
            provinceData: [
                { name: '广西壮族自治区', value: 4 },
                { name: '贵州省', value: 4 },
                { name: '天津', value: 4 },
                { name: '北京', value: 13 },
                { name: '云南省', value: 7 },
                { name: '湖南省', value: 3 },
                { name: '浙江省', value: 1 },
                { name: '河南省', value: 3 },
                { name: '江西省', value: 6 },
                { name: '甘肃省', value: 2 },
                { name: '西藏自治区', value: 1 },
                { name: '安徽省', value: 1 },
                { name: '山西省', value: 1 },
                { name: '黑龙江省', value: 1 },
                { name: '陕西省', value: 4 },
                { name: '福建省', value: 3 },
                { name: '上海', value: 3 },
                { name: '四川省', value: 1 },
                { name: '宁夏回族自治区', value: 2 },
                { name: '辽宁省', value: 2 },
                { name: '广东省', value: 5 },
                { name: '河北省', value: 2 },
                { name: '重庆', value: 1 },
                { name: '江苏省', value: 1 },
                { name: '湖北省', value: 1 },
                { name: '新疆维吾尔自治区', value: 3 },
                { name: '内蒙古自治区', value: 1 },
            ],
        },
    }
    let spans = document.querySelectorAll('.row .font-weight-bold')
    const data = obj.data.overview
    let n = 0
    for (const k in data) {
        spans[n].innerHTML = data[k]
        n++
    }


    const myChart = echarts.init(document.getElementById('line'))

    // 指定图表的配置项和数据
    const option = {
        title: {
            text: '2021全学科薪资走势',
            left: 10,
            top: 15,
            textStyle: {
                fontSize: 16,
            },
        },
        xAxis: {
            type: 'category',
            data: ['1月', '2月', '3月', '4月', '5月', '6月'],
            axisLine: {
                show: true,
                lineStyle: {
                    color: 'green',
                    type: 'dashed'
                }
            },
            axisLabel: {
                show: true,
                color: 'red'
            }
        },
        yAxis: {
            type: 'value',
            splitLine: {
                lineStyle: {
                    type: 'dashed',
                    color: ['#ccc']
                }
            }
        },
        tooltip: {
            show: true,
            trigger: 'axis',
        },
        grid: {
            left: '10%',
            top: '20%',
        },
        color: [
            {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 1,
                y2: 1,
                colorStops: [
                    {
                        offset: 0,
                        color: 'red', // 0% 处的颜色
                    },
                    {
                        offset: 1,
                        color: 'orange', // 100% 处的颜色
                    },
                ],
            },
        ],

        series: [
            {
                data: [820, 932, 901, 934, 1290, 1330, 1320],
                type: 'line',
                smooth: true,
                symbol: 'emptyCircle',
                symbolSize: 10,
                lineStyle: {
                    width: 5,
                },
                areaStyle: {
                    color: {
                        type: 'linear',
                        x: 0,
                        y: 0,
                        x2: 0,
                        y2: 1,
                        colorStops: [
                            {
                                offset: 0,
                                color: '#ffdc88', // 0% 处的颜色
                            },
                            {
                                offset: 0.8,
                                color: 'rgba(255,255,255,0.1)', // 0% 处的颜色
                            },
                            {
                                offset: 1,
                                color: 'rgba(255,255,255,0)', // 100% 处的颜色
                            },
                        ],
                    },
                },
            },
        ],
    }

    // 使用刚指定的配置项和数据显示图表。
    // myChart.setOption(option)
    // function fn() {
    //     const months = obj.data.year.map(item => item.month)
    //     const salarys = obj.data.year.map(item => item.salary)
    //     option.xAxis.data = months
    //     option.series[0].data = salarys
    //     myChart.setOption(option)
    // }
    // fn()

    function fn() {
        const months = obj.data.year.map(item => item.month)
        const salarys = obj.data.year.map(item => item.salary)
        option.xAxis.data = months
        option.series[0].data = salarys
        myChart.setOption(option)
    }
    fn()












    const initMapChart = () => {
        const myEchart = echarts.init(document.querySelector('#map'))

        const dataList = [
            { name: '南海诸岛', value: 0 },
            { name: '北京', value: 0 },
            { name: '天津', value: 0 },
            { name: '上海', value: 0 },
            { name: '重庆', value: 0 },
            { name: '河北', value: 0 },
            { name: '河南', value: 0 },
            { name: '云南', value: 0 },
            { name: '辽宁', value: 0 },
            { name: '黑龙江', value: 0 },
            { name: '湖南', value: 0 },
            { name: '安徽', value: 0 },
            { name: '山东', value: 0 },
            { name: '新疆', value: 0 },
            { name: '江苏', value: 0 },
            { name: '浙江', value: 0 },
            { name: '江西', value: 0 },
            { name: '湖北', value: 0 },
            { name: '广西', value: 0 },
            { name: '甘肃', value: 0 },
            { name: '山西', value: 0 },
            { name: '内蒙古', value: 0 },
            { name: '陕西', value: 0 },
            { name: '吉林', value: 0 },
            { name: '福建', value: 0 },
            { name: '贵州', value: 0 },
            { name: '广东', value: 0 },
            { name: '青海', value: 0 },
            { name: '西藏', value: 0 },
            { name: '四川', value: 0 },
            { name: '宁夏', value: 0 },
            { name: '海南', value: 0 },
            { name: '台湾', value: 0 },
            { name: '香港', value: 0 },
            { name: '澳门', value: 0 },
        ]

        let option = {
            title: {
                text: '籍贯分布',
                top: 10,
                left: 10,
                textStyle: {
                    fontSize: 16,
                },
            },
            tooltip: {
                trigger: 'item',
                formatter: '{b}: {c} 位学员',
                borderColor: 'transparent',
                backgroundColor: 'rgba(0,0,0,0.5)',
                textStyle: {
                    color: '#fff',
                },
            },
            visualMap: {
                min: 0,
                max: 6,
                left: 'left',
                bottom: '20',
                text: ['6', '0'],
                inRange: {
                    color: ['#ffffff', '#0075F0'],
                },
                show: true,
                left: 40,
            },
            geo: {
                map: 'china',
                roam: false,
                zoom: 1.0,
                label: {
                    normal: {
                        show: true,
                        fontSize: '10',
                        color: 'rgba(0,0,0,0.7)',
                    },
                },
                itemStyle: {
                    normal: {
                        borderColor: 'rgba(0, 0, 0, 0.2)',
                        color: '#e0ffff',
                    },
                    emphasis: {
                        areaColor: '#34D39A',
                        shadowOffsetX: 0,
                        shadowOffsetY: 0,
                        shadowBlur: 20,
                        borderWidth: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)',
                    },
                },
            },
            series: [
                {
                    name: '籍贯分布',
                    type: 'map',
                    geoIndex: 0,
                    data: dataList,
                },
            ],
        }

        myEchart.setOption(option)
        function fn1() {
            const provinceDatas = obj.data.provinceData
            provinceDatas.forEach(item =>{
                const name = item.name.substring(0,2)//截取字符串 
                const i = dataList.findIndex(item => item.name.substring(0,2) === name)
                dataList[i].value = item.value

                myEchart.setOption(option)
            })
        }
        fn1()
    }
    initMapChart()
})();







